﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Model;
using BLL;

public partial class WebControl_Info : System.Web.UI.UserControl
{
    UserBLL bll = new UserBLL();
    SessionUser sUser = BaseLogin.getSessionNode(HttpContext.Current);

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            User user = bll.GetModel(sUser.uid);
            this.txtUserName.Text = user.userName;
            this.txtCompany.Text = user.company;
            this.txtLinkman.Text = user.linkman;
            this.txtQQ.Text = user.qq;
            this.txtEMail.Text = user.email;
            this.txtTel.Text = user.tel;
            this.txtMobilePhone.Text = user.mobilePhone;
            this.txtFax.Text = user.fax;
            this.txtComment.Text = user.comment;
            this.txtBriefIntro.InnerHtml = user.briefIntro;
        }
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        User user = new User();
        user.uid = sUser.uid;
        user.userName = this.txtUserName.Text;
        user.company = this.txtCompany.Text;
        user.linkman = this.txtLinkman.Text;
        user.qq = this.txtQQ.Text;
        user.email = this.txtEMail.Text;
        user.tel = this.txtTel.Text;
        user.mobilePhone = this.txtMobilePhone.Text;
        user.fax = this.txtFax.Text;
        user.comment = this.txtComment.Text;
        user.briefIntro = Request.Form["txtBriefIntro"];
        if (bll.Update(user))
        {
            Response.Write("<script>alert('修改成功！')</script>");
        }
        else
        {
            Response.Write("<script>alert('修改失败！')</script>");
        }
    }
}
